package cn.edu.zafu.bigdata.lhff;

public record Cube(double length, double width, double height) {

    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        Cube other = (Cube) obj;
        return Double.compare(length, other.length) == 0 &&
                Double.compare(width, other.width) == 0 &&
                Double.compare(height, other.height) == 0;
    }

    public int hashCode() {
        return java.util.Objects.hash(length, width, height);
    }

    public static void main(String[] args) {
        Cube cube1 = new Cube(3.0, 3.0, 3.0);
        Cube cube2 = new Cube(3.0, 3.0, 3.0);
        Cube cube3 = new Cube(4.0, 4.0, 4.0);

        System.out.println("cube1.equals(cube2): " + cube1.equals(cube2));
        System.out.println("cube1.equals(cube3): " + cube1.equals(cube3));
        System.out.println("cube2.equals(cube3): " + cube2.equals(cube3));
        System.out.println("Height of cube1: " + cube1.height());
    }
}